package br.com.redefranciscanas.wiki.view;

import java.util.List;

import javax.faces.context.FacesContext;

import br.com.redefranciscanas.wiki.domain.Item;
import br.com.redefranciscanas.wiki.domain.Topico;
import br.com.redefranciscanas.wiki.persistence.ItemDao;
import br.com.redefranciscanas.wiki.persistence.TopicoDao;

public class BuscaMB {
	private Long id;
	private Topico topico;
	private TopicoDao tdao;
	private List<Item> item;
	private ItemDao idao;
	private Object value;

	public BuscaMB() {
		limpa();
		value = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id");
		id = Long.parseLong((String) value);
		tdao = new TopicoDao();
		topico = tdao.buscaTopicoPeloId(id);
		idao = new ItemDao();
		item = idao.buscaItemPeloIdTopico(id);
	}

	private void limpa() {
		item = null;
		topico = null;
		id = null;
		value = null;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Topico getTopico() {
		return topico;
	}

	public List<Item> getItem() {
		return item;
	}

}
